<?php namespace App\Client\Base\Criterias;

use Auth;
use App\Core\Exceptions\InputError;
use App\Core\Repository\Criteria;
use App\Core\Repository\Repository;

class MatchClient extends Criteria{

    public function apply(Repository $repository){
        parent::apply($repository);
        $user = Auth::user();
        $supplier = $user->supplier;
        if(!$supplier){
            throw new InputError('非法操作');
        }
        $this->query->where($this->formatField($this->model, 'supplier_id'), '=', $supplier->id);
    }
}